//为管道加载动态流动效果
mainPipe.className.baseVal="runing";
heatPipe.className.baseVal="";
handlePipe.className.baseVal="runing";
drainPipe.className.baseVal="runing";

var baseX=-10;
var baseY=40;

document.getElementById("topLine").setAttribute("points",replePoints("0,40 1800,40",baseX,baseY));
document.getElementById("rightLine").setAttribute("points",replePoints("1350,40 1350,730",baseX,baseY));
document.getElementById("rightLine1").setAttribute("points",replePoints("1350,380 1800,380",baseX,baseY));
document.getElementById("mainPipe").setAttribute("points",replePoints("125,325 125,175 980,175 980,650 125,650 125,325",baseX,baseY));
document.getElementById("handlePipe").setAttribute("points",replePoints("700,645 700,175 980,175 980,650 700,650",baseX,baseY));

document.getElementById("m1").setAttribute("points",replePoints("122,172 980,172",baseX,baseY));
document.getElementById("m2").setAttribute("points",replePoints("128,178 980,178",baseX,baseY));
document.getElementById("m3").setAttribute("points",replePoints("983,175 983,650",baseX,baseY));
document.getElementById("m4").setAttribute("points",replePoints("977,175 977,650",baseX,baseY));
document.getElementById("m5").setAttribute("points",replePoints("980,653 122,653",baseX,baseY));
document.getElementById("m6").setAttribute("points",replePoints("980,647 128,647",baseX,baseY));
document.getElementById("m7").setAttribute("points",replePoints("128,647 128,178",baseX,baseY));
document.getElementById("m8").setAttribute("points",replePoints("122,653 122,172",baseX,baseY));

document.getElementById("h1").setAttribute("points",replePoints("703,648 703,177",baseX,baseY));
document.getElementById("h2").setAttribute("points",replePoints("697,648 697,177",baseX,baseY));

document.getElementById("heatPipe").setAttribute("points",replePoints("980,175 1140,175 1140,165 980,165 980,175",baseX,baseY));
document.getElementById("drainPipe").setAttribute("points",replePoints("980,650 1105,650",baseX,baseY));
document.getElementById("ps1").setAttribute("points",replePoints("980,653 1105,653",baseX,baseY));
document.getElementById("ps2").setAttribute("points",replePoints("980,647 1105,647",baseX,baseY));
setXY("psText",1120,655,baseX,baseY);
document.getElementById("O1").setAttribute("points",replePoints("551,360 980,360",baseX,baseY));
document.getElementById("O2").setAttribute("points",replePoints("505,360 200,360",baseX,baseY));
//document.getElementById("NH1").setAttribute("points",replePoints("552,210 552,160",baseX,baseY));
//document.getElementById("NH2").setAttribute("points",replePoints("552,160 980,160",baseX,baseY));

setXY("xczone",30,280,baseX,baseY);
setXY("xcText",125,375,baseX,baseY);

setXY("yyzone",900,100,baseX,baseY);
setXY("yyText",965,170,baseX,baseY);

setXY("hyzone",900,250,baseX,baseY);
setXY("hyText",965,320,baseX,baseY);

setXY("cjzone",900,400,baseX,baseY);
setXY("cjText",965,470,baseX,baseY);

setXY("cszone",900,550,baseX,baseY);
setXY("csText",965,620,baseX,baseY);

setXY("glzone",1120,140,baseX,baseY);

setXY("wdtap",1090,153,baseX,baseY);
setCXCY("wdColor",1100,195,baseX,baseY);
setXY("wdText",1110,200,baseX,baseY);

setXY("maintap",683,620,baseX,baseY);
setXY("mainText",683,680,baseX,baseY);

setXY("draintap",1070,620,baseX,baseY);
setCXCY("drainColor",1080,667,baseX,baseY);
setXY("drainText",1090,672,baseX,baseY);

setXY("Otap",480,360,baseX,baseY);
setCXCY("OColor",565,445,baseX,baseY);
setXY("OText",575,450,baseX,baseY);
setXY("OLab",512,475,baseX,baseY);

// setXY("NHtap",480,210,baseX,baseY);
// setCXCY("NHColor",565,295,baseX,baseY);
// setXY("NHText",575,300,baseX,baseY);
// setXY("NHLab",512,325,baseX,baseY);

/// /右上图标说明
var smX=740;
var smY=40;
setCXCY("sm1",smX,smY,baseX,baseY+30);
setXY("sm2",smX+14,smY+5,baseX,baseY+30);
setCXCY("sm3",smX+65,smY,baseX,baseY+30);
setXY("sm4",smX+65+15,smY+5,baseX,baseY+30);
setCXCY("sm5",smX+130,smY,baseX,baseY+30);
setXY("sm6",smX+130+15,smY+5,baseX,baseY+30);
setCXCY("sm7",smX+195,smY,baseX,baseY+30);
setXY("sm8",smX+195+15,smY+5,baseX,baseY+30);
setCXCY("sm9",smX+260,smY,baseX,baseY+30);
setXY("sm10",smX+260+15,smY+5,baseX,baseY+30);
setCXCY("sm11",smX+325,smY,baseX,baseY+30);
setXY("sm12",smX+325+15,smY+5,baseX,baseY+30);
setCXCY("sm13",smX+390,smY,baseX,baseY+30);
setXY("sm14",smX+390+15,smY+5,baseX,baseY+30);
setCXCY("sm15",smX+455,smY,baseX,baseY+30);
setXY("sm16",smX+455+15,smY+5,baseX,baseY+30);
setCXCY("sm17",smX+520,smY,baseX,baseY+30);
setXY("sm18",smX+520+15,smY+5,baseX,baseY+30);

function replePoints(points,baseX,baseY) {
    var arr = points.split(" ");
    var newArr = new Array();
    var newPoints="";
    for (var i=0;i<arr.length;i++){
        x = parseInt(arr[i].split(",")[0])+baseX;
        y = parseInt(arr[i].split(",")[1])+baseY;
        newArr.push(x+","+y);
    }
    for (var i=0;i<newArr.length;i++){
        newPoints = newPoints+newArr[i]+" ";
    }
    return newPoints;
}

function setXY(elementId,x,y,baseX,baseY) {
    var element = document.getElementById(elementId);
    if (element != null){
        element.setAttribute("x",x+baseX);
        element.setAttribute("y",y+baseY);
    }
}

function setCXCY(elementId,x,y,baseX,baseY) {
    var element = document.getElementById(elementId);
    if (element != null){
        element.setAttribute("cx",x+baseX);
        element.setAttribute("cy",y+baseY);
    }
}

Date.prototype.toString = function() {
    return this.getFullYear()
        + "-" + (this.getMonth()>8?(this.getMonth()+1):"0"+(this.getMonth()+1))
        + "-" + (this.getDate()>9?this.getDate():"0"+this.getDate())
        + " " + (this.getHours()>9?this.getHours():"0"+this.getHours())
        + ":" + (this.getMinutes()>9?this.getMinutes():"0"+this.getMinutes())
        + ":" + (this.getSeconds()>9?this.getSeconds():"0"+this.getSeconds());
}
